{% extends 'base.html' %}

{% load staticfiles %}

{% block title %}文件管理 - 人员详情{% endblock %}

{% block custome_css %}
    <link rel="stylesheet" href="{% static 'files/css/upload.css' %}">
    <link rel="stylesheet" href="{% static 'files/css/detail.css' %}">
{% endblock %}

{% block content %}
    <div class="content">
        <p class="content-note1">修改人员<span class="content-note2"> (标注为*为必填项)</span></p>
        <div style="clear:both"></div>
        <form class="form-table" action="{% url 'users:modify' %}" method="post">
            <input type="hidden" id="user_id" name="user_id" value="{{ user.id }}"/>
            <div class="form-list">
                <span>*工号</span><input {% if userinfo_form.errors.userno %}class="input-error"{% endif %} type="text" id="userno" name="userno" value="{{ user.userno }}"/>
            </div>
            <div class="form-list">
                <span>*姓名</span><input {% if userinfo_form.errors.username %}class="input-error"{% endif %} type="text" id="username" name="username" value="{{ user.username }}"/>
            </div>
            <div class="form-list">
                <span>部门</span><input {% if userinfo_form.errors.department %}class="input-error"{% endif %} type="text" name="department" value="{{ user.department }}" placeholder="不超过15个字符"/>
            </div>
            <div class="form-list">
                <span>角色</span>
                <select name="role">
                    <option value="3" {% ifequal user.role '3' %}selected{% endifequal %}>监察稽核员</option>
                    <option value="2" {% ifequal user.role '2' %}selected{% endifequal %}>系统管理员</option>
                    <option value="1" {% ifequal user.role '1' %}selected{% endifequal %}>普通员工</option>
                    <option value="0" {% ifequal user.role '0' %}selected{% endifequal %}>离职员工</option>
                </select>
            </div>
            <div class="form-list">
                <span>子角色</span>
                <select name="sub_role">
                    <option value="2" {% ifequal user.sub_role '2' %}selected{% endifequal %}>二审员</option>
                    <option value="1" {% ifequal user.sub_role '1' %}selected{% endifequal %}>初审员</option>
                    <option value="0" {% ifequal user.sub_role '0' %}selected{% endifequal %}>无</option>
                </select>
            </div>
            {% if msg %}
                <div class="error">{{ msg }}</div>
            {% endif %}
            <div style="clear:both"></div>
            <div class="form-list">
                <input class="form-button" type="submit" value="保存"/>
            </div>
            <div class="form-list">
                 <button class="form-button" type="button" onclick="btn_cancel()">取消</button>
            </div>
            <div class="form-list">
                 <button class="form-button form-button-pwdreset" type="button" onclick="btn_pwdreset()">重置密码</button>
            </div>
            {% csrf_token %}
        </form>
</div>
{% endblock %}

{% block custome_js %}
    <script>
        function btn_cancel() {
            location.href = "{% url 'users:list' %}";
        }

        function btn_pwdreset() {
            var user_id = document.getElementById("user_id").value;
            var url = "{% url 'users:pwdreset' 0 %}";
            location.href = url.replace('0', user_id);
        }
    </script>
{% endblock %}
